from flask import Flask
from sqlalchemy import Column, DateTime, Integer, String, desc
from sqlalchemy.schema import FetchedValue
from flask_sqlalchemy import SQLAlchemy
import pymysql
from controllers.config import *

app = Flask(__name__)
pymysql.install_as_MySQLdb()


class Config(object):
    """配置参数"""
    # 设置连接数据库的URL
    app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://%s:%s@%s:%s/%s' % (DB_USER, DB_PWD, DB_HOST, DB_PORT, DB_NAME)

    # 设置sqlalchemy自动更跟踪数据库
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 查询时会显示原始SQL语句
    app.config['SQLALCHEMY_ECHO'] = False

    # 禁止自动提交数据处理
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = False


# 读取配置
app.config.from_object(Config)

# 创建数据库sqlalchemy工具对象
db = SQLAlchemy(app)


class Role(db.Model):
    # 定义表名
    __tablename__ = 'roles'
    # 定义字段
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(64), unique=True)
    users = db.relationship('User', backref='role')  # 反推与role关联的多个User模型对象


class User(db.Model):
    # 定义表名
    __tablename__ = 'users'
    # 定义字段
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(64), unique=True, index=True)
    email = db.Column(db.String(64), unique=True)
    pswd = db.Column(db.String(64))
    role_id = db.Column(db.Integer, db.ForeignKey('roles.id'))  # 设置外键


class Project(db.Model):
    __tablename__ = 'project'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    iap = db.Column(db.Text)
    basic = db.Column(db.Text)
    classify = db.Column(db.Text)
    view = db.Column(db.Text)
    purchase_limit = db.Column(db.Text)
    bonus = db.Column(db.Text)


class LuckyCard(db.Model):
    __tablename__ = 'lucky_card'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    big_reward = db.Column(db.Text)
    card_reward = db.Column(db.Text)


class LuckyWheel(db.Model):
    __tablename__ = 'lucky_wheel'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    big_reward = db.Column(db.Text)
    wheel_reward = db.Column(db.Text)
    goal_reward = db.Column(db.Text)


class CastleLv(db.Model):
    __tablename__ = 'castle_lv'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    castle_lv = db.Column(db.Text)


class ContinuousActivities(db.Model):
    __tablename__ = 'continuous_activities'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    task_group = db.Column(db.Text)
    task_chest_reward = db.Column(db.Text)
    top_reward = db.Column(db.Text)


class ContinuousTaskList(db.Model):
    __tablename__ = 'continuous_task_list'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    task_type = db.Column(db.Text)
    op_type = db.Column(db.Text)
    detail_type = db.Column(db.Text)
    detail_id = db.Column(db.Text)
    label = db.Column(db.Text)


class NoviceRecharge(db.Model):
    __tablename__ = 'novice_recharge'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    goal_list = db.Column(db.Text)


class MultidayRecharge(db.Model):
    __tablename__ = 'multiday_recharge'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    target = db.Column(db.Text)


class EvipShopItem(db.Model):
    __tablename__ = 'evip_shop_item'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    goods = db.Column(db.Text)
    remark = db.Column(db.Text)


class MysteriousMerchant(db.Model):
    __tablename__ = 'mysterious_merchant'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    goods = db.Column(db.Text)


class MonumentTask(db.Model):
    __tablename__ = 'monument_task'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    name = db.Column(db.Text)
    task_class = db.Column(db.Text)
    task_num = db.Column(db.Text)
    task_level = db.Column(db.Text)
    target = db.Column(db.Text)
    rank_type = db.Column(db.Text)
    op_type = db.Column(db.Text)
    has_rank = db.Column(db.Text)


class Monument(db.Model):
    __tablename__ = 'monument'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    localization = db.Column(db.Text)
    tasks = db.Column(db.Text)
    remark = db.Column(db.String)


class TargetActivity(db.Model):
    __tablename__ = 'target_activity'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    task_group = db.Column(db.Text)
    # remark = db.Column(db.String)


class TargetActivityList(db.Model):
    __tablename__ = 'target_activity_list'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    task_type = db.Column(db.Text)
    op_type = db.Column(db.Text)
    detail_type = db.Column(db.Text)
    detail_id = db.Column(db.Text)
    label = db.Column(db.Text)


class StrongestSheriff(db.Model):
    __tablename__ = 'strongest_sheriff'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)


class StrongestSheriffSub(db.Model):
    __tablename__ = 'strongest_sheriff_sub'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    mid = db.Column(db.Text)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)


class StrongestSheriffTask(db.Model):
    __tablename__ = 'strongest_sheriff_score'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    doc_id = db.Column(db.Text)
    target_unit = db.Column(db.Text)
    show_type = db.Column(db.Text)


class TerritoryEvent(db.Model):
    __tablename__ = 'territory_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)


class LoharEvent(db.Model):
    __tablename__ = 'lohar_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    top_reward = db.Column(db.Text)
    kill_reward = db.Column(db.Text)
    rate_list = db.Column(db.Text)


class SpecialMapDis(db.Model):
    __tablename__ = 'special_map_dis'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    conf = db.Column(db.Text)


class NewAllianceEvent(db.Model):
    __tablename__ = 'new_alliance_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    calc_score = db.Column(db.Text)
    reward = db.Column(db.Text)
    extern0 = db.Column(db.Text)


class NewPersonalEvent(db.Model):
    __tablename__ = 'new_personal_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    calc_score = db.Column(db.Text)
    reward = db.Column(db.Text)
    extern0 = db.Column(db.Text)


class NewAllianceEventScore(db.Model):
    __tablename__ = 'new_alliance_event_score'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    doc_id = db.Column(db.Text)
    score_type = db.Column(db.Text)


class NewPersonalEventScore(db.Model):
    __tablename__ = 'new_personal_event_score'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    doc_id = db.Column(db.Text)
    target_unit = db.Column(db.Text)
    show_type = db.Column(db.Text)


class NoticeEvent(db.Model):
    __tablename__ = 'notice_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    top_reward = db.Column(db.Text)
    navigation = db.Column(db.Text)


class MakeCakeEvent(db.Model):
    __tablename__ = 'make_cake_event'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    goal_reward = db.Column(db.Text)
    extern0 = db.Column(db.Text)


class BattlePass(db.Model):
    __tablename__ = 'battle_pass'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    goal_reward = db.Column(db.Text)
    extra_reward = db.Column(db.Text)
    points_reward = db.Column(db.Text)
    privilege = db.Column(db.Text)
    normal_task = db.Column(db.Text)
    special_task = db.Column(db.Text)


class BattlePassTask(db.Model):
    __tablename__ = 'battle_pass_task'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    data = db.Column(db.Text)
    idx = db.Column(db.Text)


class LostBattlefield(db.Model):
    __tablename__ = 'lost_battlefield_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    remark = db.Column(db.Text)
    achievement = db.Column(db.Text)
    localization = db.Column(db.Text)


class Chronicle(db.Model):
    __tablename__ = 'chronicle_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    localization = db.Column(db.Text)
    min_castle_lv = db.Column(db.Text)
    tasks = db.Column(db.Text)
    remark = db.Column(db.Text)


class WarriorProj(db.Model):
    __tablename__ = 'warrior_journey_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    calc_score = db.Column(db.Text)
    reward = db.Column(db.Text)


class WarriorJourneyEventScore(db.Model):
    __tablename__ = 'warrior_journey_event_score'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    score_type = db.Column(db.Text)
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    doc_id = db.Column(db.Text)


class LostAchievenemtProj(db.Model):
    __tablename__ = 'lost_achievenemt_event_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    task = db.Column(db.Text)
    reward = db.Column(db.Text)


class LostAchievenemtAction(db.Model):
    __tablename__ = 'lost_achievenemt_event_action'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    score_type = db.Column(db.Text)
    add_type = db.Column(db.Text)
    doc_id = db.Column(db.Text)


class LostAchievenemtHonor(db.Model):
    __tablename__ = 'lost_achievenemt_event_honor'

    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    type = db.Column(db.Text)
    id_list = db.Column(db.Text)
    num = db.Column(db.Text)
    score = db.Column(db.Text)
    doc_id = db.Column(db.Text)
    score_type = db.Column(db.Text)


class MultiGrowthGiftProject(db.Model):
    __tablename__ = 'multi_growth_gift_project'

    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic_data = db.Column(db.Text)
    localization = db.Column(db.Text)
    level_task_list = db.Column(db.Text)
    remark = db.Column(db.Text)


class ZhengDuoProject(db.Model):
    __tablename__ = 'zhengduo_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    main = db.Column(db.Text)
    localization = db.Column(db.Text)
    standard = db.Column(db.String)
    special = db.Column(db.Text)
    alliance_config = db.Column(db.Text)
    remark = db.Column(db.String)


class MuBiaoXingProject(db.Model):
    __tablename__ = 'mubiaoxing_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    task = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.String)


class XinGeRenProject(db.Model):
    __tablename__ = 'xingeren_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    task = db.Column(db.Text)
    localization = db.Column(db.Text)
    goal_reward = db.Column(db.Text)
    rank_reward = db.Column(db.Text)
    remark = db.Column(db.String)
    rank_limit = db.Column(db.Integer)


class EventTypeMailSend(db.Model):
    __tablename__ = 'event_type_mail_send'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    iron_throne = db.Column(db.Text)
    super_throne = db.Column(db.Text)
    svs = db.Column(db.Text)
    other = db.Column(db.Text)


class BackflowMainProj(db.Model):
    __tablename__ = 'backflow_main_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    login_reward = db.Column(db.Text)
    task_group = db.Column(db.Text)
    consume_group = db.Column(db.Text)
    remark = db.Column(db.String)
    iap_group = db.Column(db.Text)
    score_reward = db.Column(db.Text)
    main_localization = db.Column(db.Text)
    login_localization = db.Column(db.Text)
    consume_localization = db.Column(db.Text)
    task_localization = db.Column(db.Text)
    iap_localization = db.Column(db.Text)
    task_doc_localization = db.Column(db.Text)
    day_doc_localization = db.Column(db.Text)
    migration_localization = db.Column(db.Text)
    benefits = db.Column(db.Text)
    new_journey = db.Column(db.Text)
    multiday_recharge = db.Column(db.Text)
    store_treasure = db.Column(db.Text)
    inheritance = db.Column(db.Text)
    new_journey_login_reward = db.Column(db.Text)
    new_journey_task_group = db.Column(db.Text)
    new_journey_score_reward = db.Column(db.Text)
    new_journey_iap_group = db.Column(db.Text)
    new_journey_multiday_recharge = db.Column(db.Text)
    new_journey_store_treasure = db.Column(db.Text)


class RechargeRebateProject(db.Model):
    __tablename__ = 'recharge_rebate_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    task_list = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.String)


class NoviceRechargeRebateProject(db.Model):
    __tablename__ = 'novice_recharge_rebate_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    task_list = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.String)


class TargetActivityProj(db.Model):
    __tablename__ = 'target_activity_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    task_group = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ContinuousActivitiesProj(db.Model):
    __tablename__ = 'continuous_activities_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    top_reward = db.Column(db.Text)
    task_chest_reward = db.Column(db.Text)
    task_group = db.Column(db.Text)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class CustomizeIapProject(db.Model):
    __tablename__ = 'customize_iap_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    localization = db.Column(db.Text)
    free_chest_reward = db.Column(db.Text)
    chest_config = db.Column(db.Text)
    remark = db.Column(db.String)


class ScoreThemeBattlePassProject(db.Model):
    __tablename__ = 'score_theme_battle_pass_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.String)
    localization = db.Column(db.Text)
    unlock_item_id = db.Column(db.Integer)
    task = db.Column(db.Text)
    max_task_id = db.Column(db.Integer)
    score_reward = db.Column(db.Text)
    instant_reward = db.Column(db.Text)
    task_extra_reward = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class TaskThemeBattlePassProject(db.Model):
    __tablename__ = 'task_theme_battle_pass_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.String)
    localization = db.Column(db.Text)
    unlock_item_id = db.Column(db.Integer)
    task = db.Column(db.Text)
    max_task_id = db.Column(db.Integer)
    instant_reward = db.Column(db.Text)
    task_extra_reward = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class TaskThemeBattlePassScoreConfig(db.Model):
    __tablename__ = 'task_theme_battle_pass_score_config'
    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    task_type = db.Column(db.Integer)
    target = db.Column(db.Integer)
    target_unit = db.Column(db.Integer)
    detail_id = db.Column(db.Integer)
    detail_level = db.Column(db.Integer)
    remark = db.Column(db.String)
    doc_id = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ScoreThemeBattlePassScoreConfig(db.Model):
    __tablename__ = 'score_theme_battle_pass_score_config'
    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    task_type = db.Column(db.Integer)
    target = db.Column(db.Integer)
    target_unit = db.Column(db.Integer)
    detail_id = db.Column(db.Integer)
    detail_level = db.Column(db.Integer)
    remark = db.Column(db.String)
    score = db.Column(db.Integer)  # 多一个积分
    doc_id = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class GoldRushProject(db.Model):
    __tablename__ = 'gold_rush_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    localization = db.Column(db.Text)
    task_group = db.Column(db.Text)
    max_task_num = db.Column(db.Integer)
    score_rule = db.Column(db.Integer)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class StoreTreasureProject(db.Model):
    __tablename__ = 'store_treasure_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.String)
    localization = db.Column(db.Text)
    task_group = db.Column(db.Text)
    max_task_num = db.Column(db.Integer)
    score_rule = db.Column(db.Integer)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ShopProject(db.Model):
    __tablename__ = 'shop_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    title = db.Column(db.Text)
    goods = db.Column(db.Text)
    remark = db.Column(db.String)
    shop_name = db.Column(db.String)


class ShopName(db.Model):
    __tablename__ = 'shop_name'
    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    name = db.Column(db.Text)


class ShopSchedule(db.Model):
    __tablename__ = 'shop_schedule'
    id = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    data = db.Column(db.Text)


class WesternShadowMenuProject(db.Model):
    __tablename__ = 'western_shadow_menu_project'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    score_type_list = db.Column(db.Text)
    reward = db.Column(db.Text)
    remark = db.Column(db.String)
    rank_reward_score_limit = db.Column(db.Integer)
    hosptal = db.Column(db.Text)
    max_score_type_id = db.Column(db.Integer)
    revive = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class DuelYardEventProj(db.Model):
    __tablename__ = 'duel_yard_event_proj'
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.String)
    goal_reward = db.Column(db.Text)
    title = db.Column(db.Text)
    remark = db.Column(db.String)


class ExtremeUserEventProject(db.Model):
    __tablename__ = "extreme_user_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    event_type = db.Column(db.Integer)
    rank = db.Column(db.String)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ExtremeUserScoreType(db.Model):
    __tablename__ = "extreme_user_score_type"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ExtremeUserTaskPool(db.Model):
    __tablename__ = "extreme_user_task_pool"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ExtremeUserEventSchedule(db.Model):
    __tablename__ = "extreme_user_event_schedule"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class MatchNumericalConf(db.Model):
    __tablename__ = "match_numerical_conf"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    ava = db.Column(db.Text)
    legion = db.Column(db.Text)
    new_legion = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class KvkEventProject(db.Model):
    __tablename__ = "kvk_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    top_reward = db.Column(db.Text)
    user_goal_reward_list = db.Column(db.Text)
    al_goal_reward_list = db.Column(db.Text)
    user_rank_reward = db.Column(db.Text)
    win_reward = db.Column(db.Text)
    lost_reward = db.Column(db.Text)
    score_type_list = db.Column(db.Text)
    hosptal = db.Column(db.Text)
    remark = db.Column(db.String)
    old_localization = db.Column(db.Text)
    revive = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BuyPidRewardSend(db.Model):
    __tablename__ = "buy_pid_reward_send"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BuyRewardPidList(db.Model):
    __tablename__ = "buy_reward_pid_list"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BuyPidTriggerIapSend(db.Model):
    __tablename__ = "buy_pid_trigger_iap_send"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class AvaEventProject(db.Model):
    __tablename__ = "ava_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    reward = db.Column(db.Text)
    event_calendar = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class DailyDealsEventProject(db.Model):
    __tablename__ = "daily_deals_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class NewPersonalEventProjectV2(db.Model):
    __tablename__ = "new_personal_event_project_v2"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    reward = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class StrongestSheriffProjectV2(db.Model):
    __tablename__ = "strongest_sheriff_project_v2"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    reward = db.Column(db.Text)
    sub = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class StrongestSheriffProjectV2Sub(db.Model):
    __tablename__ = "strongest_sheriff_project_v2_sub"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    reward = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class NewAlLegionEventProject(db.Model):
    __tablename__ = "new_al_legion_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    score_type_list = db.Column(db.Text)
    localization = db.Column(db.Text)
    win_goal_reward = db.Column(db.Text)
    lost_goal_reward = db.Column(db.Text)
    rank_reward_user = db.Column(db.Text)
    rank_reward_group = db.Column(db.Text)
    match_fail_reward = db.Column(db.Text)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class OldAlLegionEventProject(db.Model):
    __tablename__ = "old_al_legion_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    localization = db.Column(db.Text)
    reward = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BettingEventProject(db.Model):
    __tablename__ = "betting_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    remark = db.Column(db.Text)
    menu = db.Column(db.Text)
    menu_stage = db.Column(db.Text)
    normal = db.Column(db.Text)
    champion = db.Column(db.Text)
    participant = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BettingEventSchedule(db.Model):
    __tablename__ = "betting_event_schedule"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)
    normal = db.Column(db.Text)
    champion = db.Column(db.Text)
    max_stage = db.Column(db.Integer)
    publish = db.Column(db.Integer)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class WorldCupSehedule(db.Model):
    __tablename__ = "world_cup_schedule"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    stage = db.Column(db.Text)
    group = db.Column(db.Text)
    left_country = db.Column(db.Text)
    right_country = db.Column(db.Text)
    left_score = db.Column(db.Text)
    right_score = db.Column(db.Text)
    utc_timestamp = db.Column(db.Integer)
    local_timestamp = db.Column(db.Integer)
    status = db.Column(db.Text)
    createdAt = db.Column(db.Integer)
    isUse = db.Column(db.Integer)
    show_date = db.Column(db.Text)
    utc_time = db.Column(db.Text)
    local_time = db.Column(db.Text)


class QuestionnaireProject(db.Model):
    __tablename__ = "questionnaire_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)


class QuestionnaireSchedule(db.Model):
    __tablename__ = "questionnaire_schedule"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)


class AlPayGiftProject(db.Model):
    __tablename__ = "al_pay_gift_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    remark = db.Column(db.Text)


class ItemTransformProject(db.Model):
    __tablename__ = "item_transform_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    detail = db.Column(db.Text)
    remark = db.Column(db.Text)

class PidBlcok(db.Model):
    __tablename__ = "pid_block"
    id = db.Column(db.Integer, primary_key=True,unique=True)
    event_type = db.Column(db.Text)
    block_id = db.Column(db.Text)
    cur_max_pid = db.Column(db.Text)
    begin_pid = db.Column(db.Text)
    end_pid = db.Column(db.Text)
    name = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

class CommonBuff(db.Model):
    __tablename__ = "common_buffs"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    name = db.Column(db.Text)
    buff = db.Column(db.Text)


class KindomBuff(db.Model):
    __tablename__ = "kindom_buff"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    name = db.Column(db.Text)
    buff = db.Column(db.Text)


class KindomBuffSchedule(db.Model):
    __tablename__ = "kindom_buff_schedule"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    begin_time = db.Column(db.Text)
    end_time = db.Column(db.Text)
    sid_list = db.Column(db.Text)
    pid = db.Column(db.Integer)

class DiscountStoreProj(db.Model):
    __tablename__ = "discount_store_proj"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    remark = db.Column(db.Text)
    goods = db.Column(db.Text)


class DiscountStoreSchedule(db.Model):
    __tablename__ = "discount_store_schedule"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    begin_time = db.Column(db.Text)
    end_time = db.Column(db.Text)
    sid_list = db.Column(db.Text)
    pid = db.Column(db.Integer)


class AuctionEventProject(db.Model):
    __tablename__ = "auction_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    goods = db.Column(db.Text)
    remark = db.Column(db.Text)

class JoyEventProject(db.Model):
    __tablename__ = "joy_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    tab = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ThemeEventProject(db.Model):
    __tablename__ = "theme_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ShamaEventProject(db.Model):
    __tablename__ = "shama_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class BanditEventProject(db.Model):
    __tablename__ = "bandit_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    localization = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class CheckTags(db.Model):
    __tablename__ = "check_tags"
    event_type = db.Column(db.Integer, primary_key=True, unique=True)
    tags = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

class StoreEventProject(db.Model):
    __tablename__ = "store_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    goal = db.Column(db.Text)
    remark = db.Column(db.String)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

class IapCouponProject(db.Model):
    __tablename__ = "iap_coupon_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    chest = db.Column(db.Text)
    remark = db.Column(db.String)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ConquestMatchEventProject(db.Model):
    __tablename__ = "conquest_match_event_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)
    reward = db.Column(db.Text)
    task_desc = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class DynamicSubGame(db.Model):
    __tablename__ = "dynamic_sub_game"
    part = db.Column(db.Text, primary_key=True)  # id 整型，主键，自增，唯一
    data = db.Column(db.Text)
    updated_at = db.Column(db.Integer, primary_key=True)  # id 整型，主键，自增，唯一

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class DynamicSubGameStorage(db.Model):
    __tablename__ = "dynamic_sub_game_storage"
    type = db.Column(db.Text, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class LuckyPurchase(db.Model):
    __tablename__ = "lucky_purchase"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    detail = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class LuckyPurchaseRewardPool(db.Model):
    __tablename__ = "lucky_purchase_reward_pool"
    type = db.Column(db.Text, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    data = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class GrowthLadder(db.Model):
    __tablename__ = "growth_ladder"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    detail = db.Column(db.Text)
    remark = db.Column(db.Text)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


class ActivityBattlepass(db.Model):
    __tablename__ = "activity_battlepass"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    basic = db.Column(db.Text)
    detail = db.Column(db.Text)
    remark = db.Column(db.Text)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

class GrowthGiftProject(db.Model):
    __tablename__ = "growth_gift_project"
    project = db.Column(db.Integer, primary_key=True, unique=True)
    basic = db.Column(db.Text)
    level_task_list = db.Column(db.Text)
    remark = db.Column(db.String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}




class ProjectVersionSnapshot(db.Model):
    __tablename__ = "project_version_snapshot"
    id = db.Column(db.Integer, primary_key=True, unique=True)
    event = db.Column(db.Text)
    hash = db.Column(db.Text)
    data = db.Column(db.String)
    file_info = db.Column(db.String)
    created_at = db.Column(db.String)
    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}


 

class NewEvipShopItem(db.Model):
    __tablename__ = "new_evip_shop_item"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)

    def to_dict(self):
        pass


class NewWgLuckyWheel(db.Model):
    __tablename__ = "new_wg_lucky_wheel"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一
    remark = db.Column(db.Text)
    calendar_conf = db.Column(db.Text)
    info = db.Column(db.Text)
    limit = db.Column(db.Text)
    basic = db.Column(db.Text)
    other = db.Column(db.Text)

    def to_dict(self):
        pass

class GuiZhen(db.Model):
    __tablename__ = "gui_zhen"
    project = db.Column(db.Integer, primary_key=True, unique=True)  # id 整型，主键，自增，唯一 
    remark = db.Column(db.Text)
    basic = db.Column(db.Text)
    version = db.Column(db.Integer)
        
    def to_dict(self):
        pass
